

// 时间戳转2021-10-18 18:18:18
function getLocalTime(timestamp) {
	const time = new Date(parseInt(timestamp) * 1000)
	
	let year=time.getFullYear(); 
	let month=time.getMonth()+1; 
	let date=time.getDate(); 
	let hour=time.getHours(); 
	let minute=time.getMinutes(); 
	let second=time.getSeconds(); 
	return `${year}-${month}-${date} ${hour}:${minute}:${second}`
}

// 手机号检查
function isPhone(phoneNum) {
	let reg = /^1[3456789]\d{9}/
	return reg.test(phoneNum)
}

// 密码强度检测
function checkPassword(val) {
	var modes = 0;
	//正则表达式验证符合要求的
	if (val.length < 6) return modes;
	if (/\d/.test(val)) modes++; //数字
	if (/[a-z]/.test(val)) modes++; //小写
	if (/[A-Z]/.test(val)) modes++; //大写  
	if (/\W/.test(val)) modes++; //特殊字符
	
	   //逻辑处理
	switch (modes) {
	    case 1:
	        return 1;
	    break;
	    case 2:
	        return 2;
		break;
	    case 3:
			
	    case 4:
	        return val.length < 12 ? 3 : 4
	        break;
	}
}

export {
	getLocalTime,
	isPhone,
	checkPassword
}
